/**
 * 
 */
package cn.ivicar.message.push.utils;

public enum EventCategoryEnum {

	VOLTAGE(1, "voltage", "6"), SHAKE(2, "shake", "5");

	private int index;
	private String value;
	private String cloudIndex;

	EventCategoryEnum(int index, String value, String cloudIndex) {
		this.index = index;
		this.value = value;
		this.cloudIndex = cloudIndex;
	}

	public int getIndex() {
		return index;
	}

	public String getValue() {
		return value;
	}

	/**
	 * @return the cloudIndex
	 */
	public String getCloudIndex() {
		return cloudIndex;
	}

	/**
	 * @param cloudIndex
	 *            the cloudIndex to set
	 */
	public void setCloudIndex(String cloudIndex) {
		this.cloudIndex = cloudIndex;
	}

	public static EventCategoryEnum get(int index) {
		switch (index) {
		case 1:
			return VOLTAGE;
		case 2:
			return SHAKE;
		default:
			return null;
		}
	}

	public static EventCategoryEnum get(String code) {

		if (VOLTAGE.getValue().equalsIgnoreCase(code)) {
			return VOLTAGE;
		} else if (SHAKE.getValue().equalsIgnoreCase(code)) {
			return SHAKE;
		} else {
			return null;
		}
	}

	public static EventCategoryEnum getByCloud(String cloudIndex) {
		if (VOLTAGE.getCloudIndex().equalsIgnoreCase(cloudIndex)) {
			return VOLTAGE;
		} else if (SHAKE.getCloudIndex().equalsIgnoreCase(cloudIndex)) {
			return SHAKE;
		} else {
			return null;
		}
	}

}
